package piaohao.util.email;

import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail;
import org.apache.commons.mail.SimpleEmail;

/**
 *
 * @author piaohao
 */
public class EmailUtil {

    public static void sendEmail(String subject, String msg, String from, String... to) {
        try {
            Email email = new HtmlEmail();
            email.setHostName("smtp.qq.com");
            email.setSmtpPort(465);
            email.setAuthentication("463168428", "piaohao19911026!");
            email.setSSLOnConnect(true);
            email.setCharset("utf8");
            email.setFrom(from);
            email.setSubject(subject);
            email.setMsg(msg);
            email.addTo(to);
            email.send();
        } catch (EmailException ex) {
            Logger.getLogger(EmailUtil.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
